/*
 * SignalHandler.cpp
 *
 *  Created on: Dec 30, 2014
 *      Author: toti
 */

#include <Misc/SignalHandler.hpp>

uint64_t SignalHandler::signalStates = 0;

SignalHandler *SignalHandler::signalHandlerInstance = 0;


SignalHandler::SignalHandler(){

}

void SignalHandler::registerSignal(int num){

	signal(num, SignalHandler::handleSignal);

}

uint64_t SignalHandler::getSignalState(uint64_t num){

	uint64_t value = signalStates & num;
	signalStates &= ~num;

	return value;


}

void SignalHandler::handleSignal(int num){

	signalStates |= (1<<(num));

}


SignalHandler *SignalHandler::instance(){
	if(signalHandlerInstance == 0){
		signalHandlerInstance = new SignalHandler();
	}
	return signalHandlerInstance;
}
